package gupao.one.jianzaozemodle;


import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;


@AllArgsConstructor
@Slf4j
@Getter
@Setter
public class User implements Cloneable {

    private String name;

    private int age ;

    private List other ;

    public User JSONDeepinClone(){
       return JSON.parseObject(JSON.toJSONBytes(this),User.class);
    }

    public static void main(String[] args) throws CloneNotSupportedException {
        List objects = new ArrayList<>();
        objects.add("11111111111111111");
        objects.add(22222);

        User user = new User("TOM",18,objects);
        User user1 = (User)user.clone();
        User user2 = user.JSONDeepinClone();

        System.out.println(user);
        System.out.println(user1);
        System.out.println(user2);

    }
}
